home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
tex
/
td187src.lzh
/
VARIABLE.I
< prev
next >
Wrap
Text File
|
1991-12-14
|
27KB
|
841 lines
IMPLEMENTATION MODULE Variablen;
FROM SYSTEM IMPORT ADDRESS , ADR;
FROM Storage IMPORT ALLOCATE , DEALLOCATE;
FROM Diverses IMPORT round, NumAlert, BlockIntersect;
FROM Types IMPORT Block, ExtendedArraySize, ObjectPtrTyp,
CodeAryTyp, DrawObjectTyp,
CharPtrTyp, ExtendedPtrTyp;
IMPORT mtAlerts ;
IMPORT mtAppl ;
IMPORT MagicVDI ;
IMPORT MagicAES ;
IMPORT MagicSys ;
IMPORT MagicConvert;
IMPORT CommonData;
IMPORT MagicStrings;
IMPORT MathLib0;
IMPORT RSCindices;
(**
IMPORT Debug;
IMPORT RTD;
**)
CONST Magic = 2905;
VAR IgnoreMode : BOOLEAN; (* Falls TRUE wird Aufruf von NewObject ignoriert *)
zoomit : BOOLEAN;
aftstr : ARRAY [1..5],[0..4] OF ARRAY [0..2] OF CHAR;
secondadr : ObjectPtrTyp;
PROCEDURE ZoomMode (zoom : BOOLEAN; factor : LONGREAL);
(*
Schaltet Zoom-Modus an/aus
*)
BEGIN
zoomit := zoom;
zoomfak := factor;
END ZoomMode;
PROCEDURE PixDistance(picdist : INTEGER) : INTEGER;
(*
Rechnet Pixel-Abstände in PIc-Abstände um und umgekehrt
*)
BEGIN
IF zoomit THEN
RETURN round(MathLib0.real(picdist) * zoomfak);
ELSE
RETURN picdist;
END;
END PixDistance;
PROCEDURE PicDistance(pixdist : INTEGER) : INTEGER;
(*
Rechnet Pixel-Abstände in PIC-Abstände um
*)
BEGIN
IF zoomit THEN
RETURN round(MathLib0.real(pixdist) / zoomfak);
ELSE
RETURN pixdist;
END;
END PicDistance;
PROCEDURE PixToPic ( xpix , ypix : INTEGER; VAR xpic , ypic : INTEGER) ;
VAR y : INTEGER ; (* leider geht y-Achse beim ST von oben nach unten *)
BEGIN
y := CommonData.OffsetXY[3] ;
IF zoomit THEN
xpic := round( MathLib0.real(xpix - CommonData.WorkArea[0]) /
zoomfak);
xpic := xpic + CommonData.ZeroX;
ypic := round( MathLib0.real(y - ypix + CommonData.WorkArea[1]) /
zoomfak );
ypic := ypic + CommonData.ZeroY;
ELSE
xpic := xpix -
CommonData.WorkArea[0] + CommonData.ZeroX;
ypic := y - ypix +
CommonData.WorkArea[1] + CommonData.ZeroY;
END;
END PixToPic ;
PROCEDURE PicToPix (VAR xpix , ypix : INTEGER; xpic , ypic : INTEGER) ;
VAR y : INTEGER ; (* leider geht y-Achse beim ST von oben nach unten *)
BEGIN
y := CommonData.OffsetXY[3] ;
IF zoomit THEN
xpix := round( zoomfak *
MathLib0.real(CommonData.FatherXOffset + xpic
- CommonData.ZeroX)) +
CommonData.WorkArea[0];
ypix := y - round( zoomfak *
MathLib0.real(CommonData.FatherYOffset + ypic
- CommonData.ZeroY)) +
CommonData.WorkArea[1];
ELSE
xpix := (CommonData.FatherXOffset + xpic - CommonData.ZeroX) +
CommonData.WorkArea[0];
ypix := y - (CommonData.FatherYOffset + ypic - CommonData.ZeroY) +
CommonData.WorkArea[1];
END;
END PicToPix ;
PROCEDURE Visible (SurroundRec : ARRAY OF INTEGER) : BOOLEAN ;
(* SurroundRec entspricht Surround in ObjectRecTyp *)
VAR X1, Y1, X2, Y2 : INTEGER;
temp : INTEGER;
result : BOOLEAN;
BEGIN
PixToPic (CommonData.ClipXY[0], CommonData.ClipXY[1], X1, Y1);
PixToPic (CommonData.ClipXY[2], CommonData.ClipXY[3], X2, Y2);
(* X1,Y1 +--------+ s0,s1 +-------+ *)
(* | | | | *)
(* | | | | *)
(* +--------+ X2,Y2 +-------+ s0+s2,s1-s3 *)
(* Keine X-Überschneidung ? *)
IF (X1>X2) THEN temp := X2; X2 := X1; X1 := temp; END;
IF (Y1<Y2) THEN temp := Y2; Y2 := Y1; Y1 := temp; END;
IF (X2<SurroundRec[0]) OR (X1>SurroundRec[0]+SurroundRec[2]) THEN
RETURN FALSE;
ELSE
(* Keine Y-Überschneidung ? *)
IF (Y2>SurroundRec[1]) OR (Y1<SurroundRec[1]-SurroundRec[3]) THEN
RETURN FALSE;
ELSE
RETURN TRUE;
END;
END;
RETURN TRUE;
END Visible;
VAR strings : ARRAY [1..4] OF ARRAY [1..19] OF CHAR;
numbers : ARRAY [1..4] OF INTEGER;
PROCEDURE Position ( ShowDelta : BOOLEAN;
XPos, YPos, XDelta, YDelta : INTEGER ) ;
(*
Zeigt die momentane Maus-Position (XPos, YPos) an. Ist ShowDelta TRUE,
so wird zusätzlich noch der Abstand zum Punkt (XDelta,YDelta) angezeigt.
*)
CONST coordlen = 11;
VAR str : ARRAY [ 0..9 ] OF CHAR ;
str2: ARRAY [ 0..9 ] OF CHAR ;
bdum : BITSET;
xm , ym ,dum , x , y : INTEGER;
i, deltax, deltay : INTEGER;
tree : POINTER TO ARRAY [ 0..255 ] OF MagicAES.OBJECT ;
xmdelta, ymdelta : INTEGER;
PROCEDURE ChangeNumber(num, index, rscindex : INTEGER);
VAR txt : ARRAY [0..127] OF CHAR;
blank : ARRAY [0..1] OF CHAR;
BEGIN
blank := ' ';
CoordToStr(num, strings[index]);
WHILE MagicStrings.Length(strings[index])<coordlen DO
MagicStrings.Insert(blank, strings[index], 0);
END;
tree^[rscindex].StringPtr := ADR(strings[index]);
numbers[index] := num;
END ChangeNumber;
PROCEDURE ShowNumber(num, x, y : INTEGER);
VAR txt : ARRAY [0..127] OF CHAR;
blank : ARRAY [0..1] OF CHAR;
BEGIN
blank := ' ';
CoordToStr(num, txt);
WHILE MagicStrings.Length(txt)<coordlen DO
MagicStrings.Insert(blank, txt, 0);
END;
MagicVDI.Text (mtAppl.VDIHandle , x, y, txt);
END ShowNumber;
PROCEDURE UpdatePosBox;
CONST DeskWin = 0 ;
VAR brec, bvis, bsect, bclip : Block;
BEGIN
i := MagicVDI.SetWritemode (mtAppl.VDIHandle , MagicVDI.REPLACE) ; (* paint *)
i := MagicVDI.SetTextcolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
MagicVDI.SetTextalignment (mtAppl.VDIHandle ,
MagicVDI.BaseJust, MagicVDI.BottomJust ,
i , i) ;
MagicAES.ObjcOffset (tree , RSCindices.posbox , brec.x , brec.y) ;
brec.y := brec.y + 1; (* oberen Rand schützen *)
brec.w := tree^ [ RSCindices.posbox ] .obWidth ;
brec.h := tree^ [ RSCindices.posbox ] .obHeight - 2; (* unteren auch *)
(* Zuerst holen wir uns mal den sichtbaren Bereich *)
MagicAES.WindGet(DeskWin, MagicAES.WFFIRSTXYWH, bvis);
WHILE (bvis.w > 0) AND (bvis.h > 0) DO
IF BlockIntersect(brec, bvis, bsect) THEN
bclip.x := bsect.x;
bclip.y := bsect.y;
bclip.w := bsect.x + bsect.w - 1;
bclip.h := bsect.y + bsect.h - 1;
MagicVDI.SetClipping (mtAppl.VDIHandle , bclip , TRUE) ;
ShowNumber(deltax, CommonData.DXPosx , CommonData.DXPosy+2);
ShowNumber(xm , CommonData.XPosx , CommonData.XPosy+2);
ShowNumber(deltay, CommonData.DYPosx , CommonData.DYPosy+2);
ShowNumber(ym , CommonData.YPosx , CommonData.YPosy+2);
MagicVDI.SetClipping (mtAppl.VDIHandle , bclip , FALSE) ;
(**
MagicAES.ObjcDraw (tree , 0 , 9 , bsect);
**)
END ;
MagicAES.WindGet(DeskWin, MagicAES.WFNEXTXYWH, bvis);
END ;
MagicVDI.SetTextalignment (mtAppl.VDIHandle ,
MagicVDI.BaseJust, MagicVDI.BaseJust,
i , i) ;
END UpdatePosBox;
BEGIN
tree := MagicAES.RsrcGaddr(MagicAES.RTREE , RSCindices.desktop) ;
x := XDelta; y := YDelta;
IF x < CommonData.WorkArea [ 0 ] THEN x := CommonData.WorkArea [ 0 ] END;
IF x > CommonData.WorkArea [ 2 ] THEN x := CommonData.WorkArea [ 2 ] END;
IF y < CommonData.WorkArea [ 1 ] THEN y := CommonData.WorkArea [ 1 ] END;
IF y > CommonData.WorkArea [ 3 ] THEN y := CommonData.WorkArea [ 3 ] END;
IF ShowDelta THEN
PixToPic (x , y , xmdelta , ymdelta) ;
END;
dum := MagicVDI.SetTextcolor (mtAppl.VDIHandle , MagicAES.BLACK) ;
x := XPos;
y := YPos;
IF x < CommonData.WorkArea [ 0 ] THEN x := CommonData.WorkArea [ 0 ] END;
IF x > CommonData.WorkArea [ 2 ] THEN x := CommonData.WorkArea [ 2 ] END;
IF y < CommonData.WorkArea [ 1 ] THEN y := CommonData.WorkArea [ 1 ] END;
IF y > CommonData.WorkArea [ 3 ] THEN y := CommonData.WorkArea [ 3 ] EN